package org.hr.organisation

import static org.junit.Assert.*
import grails.test.mixin.TestFor;

import org.junit.*

@TestFor(OrganisationService)
class OrganisationServiceTests {
	
//	OrganisationService organisationService

    @Before
    void setUp() {
//         service.generateDummyOrgStructure(3, 7);
    }

    @After
    void tearDown() {
        // Tear down logic here
    }

//    @Test
//    void testGenerateDummyOrgStructure() {
//		int level = 3
//		int teamSize = 7
//        service.generateDummyOrgStructure(level, teamSize);
//		assertEquals(level*teamSize +1,DummyUser.count)
//    }
	
	@Test
	void testConvert(){
		DummyUser boss = new DummyUser([
				userId:"boss",
				firstname:"firstname_boss",
				lastname:"lastname_boss",
				boss:null
			])
		DummyUser du = new DummyUser([
			userId:"du",
			firstname:"firstname1",
			lastname:"lastname1",
			boss:boss
		])
		UserDetails ud = service.convert(du)
		assertEquals(du.userId, ud.userId)
		assertEquals(du.firstname, ud.firstname)
		assertEquals(du.lastname, ud.lastname)
		assertEquals(du.boss?.userId, ud.bossId)
	}
	@Test
	void testGetUserDetails(){
		DummyUser du = new DummyUser([
			userId:"du",
			firstname:"firstname1",
			lastname:"lastname1",
			boss:null
		]).save()
		UserDetails ud = service.getUserDetails(du.userId)
		println(DummyUser.count())
		assertEquals(du.userId, ud.userId)
		assertEquals(du.firstname, ud.firstname)
		assertEquals(du.lastname, ud.lastname)
		assertEquals(du.boss?.userId, ud.bossId)
		
	}
	
}
